<!DOCTYPE html>
<html lang="en">

<head>
    <{include file="header.html" }>
        <title>视频课-课程管理-
            <{$user_data[ 'school_name']}>-德安信会计在线教育平台</title>
</head>

<body>
    <div class="wrap">
        <!--star left-->
        <div class="column">
            <{include file="left_menu.html" }>
        </div>
        <div id="ContMianBox">
            <!--star子栏目-->
            <div class="sub-colum">
                <div class="tit">库存管理</div>
                <ul>
                    <li class="curr"><a href="/shelves">系统网课</a></li>
                    <li><a href="/subject/system">系统题库</a></li>
                    <li><a href="/shixun">实训库存</a></li>
                </ul>
            </div>
            <!--end子栏目-->
            <!--end left-->
            <div class="container narrow">
                <!--star conter-->
                <div class="cetContent">
                    <div class="tit p-lr20">
                        <span class="curr">视频课</span>
                    </div>
                </div>
                <!--star内容区域-->
                <div class="mainScroll">
                    <div class="mainContainer line-all">
                        <!--star tabMainCont-->
                        <div class="tabMainCont">
                            <!-- <div class="tabItem m-t20">
                                <div class="form-horizontal list-filter-form">
                                    <form method="post" action="<{$current_url}>">
                                        <div class="item m-b10">
                                            <span class="p-r20">
                                        	<label class="w60">科目：</label>
                                                <select name="category[kemu]" class="text">
                                                    <option value="0">请选择</option>
                                                    <{foreach from=$subject item=item}>
                                                        <option value="<{$item.id}>" <{if $data['kemu']|default:"" eq $item.id}>selected="selected"<{/if}>><{$item.title}></option>
                                                    <{/foreach}>
                                                </select>
                                            </span>
                                            <span class="p-r20">
                                        	   <label class="w60">名称：</label>
                                                <input type="text" class="text m-r10" value="<{if $data['search']}><{$data['search']}><{/if}>" name="category[search]" placeholder="搜索内容" style="width:392px;" />
                                                <button class="zent-btn">搜索</button>
                                            </span>
                                            <span class="p-r20"></span>
                                        </div>
                                    </from>
                                </div>
                            </div> -->
                            <fieldset class="layui-elem-field">
                                <legend>按条件搜索</legend>
                                <div class="layui-field-box">
                                    <form class="layui-form layui-form-pane1" method="post" action="<{$current_url}>">
                                        <div class="layui-form-item">
                                            <div class="layui-input-inline">
                                                <select name="category[cate_id]" class="abc" lay-verify="required" id="cate_id" placeholder="请选择" lay-filter="cate_id">
                                                    <option value=0"">课程分类</option>
                                                    <{foreach from=$cate item=item}>
                                                        <option value="<{$item.id}>" <{if $data['cate_id']|default:"" eq $item.id}>selected="selected"<{/if}>><{$item.name}></option>
                                                    <{/foreach}>
                                                </select>
                                            </div>
                                            <!-- <div class="layui-inline">
                                                <select name="category[kemu]" lay-verify="required" id="subject" placeholder="请选择" lay-filter="subject">
                                                    <option value="">请选择科目</option>
                                                     <{foreach from=$subject item=item}>
                                                        <option value="<{$item.id}>" <{if $data['kemu']|default:"" eq $item.id}>selected="selected"<{/if}>><{$item.name}></option>
                                                    <{/foreach}>
                                                </select>
                                            </div> -->

                                            <div class="layui-inline">
                                                <input type="text" name="category[search]" placeholder="课程名称" value="<{if !empty($data['search']) }><{$data['search']}><{/if}>" class="layui-input">
                                            </div>

                                            <div class="layui-inline">
                                                <select name="category[sj]">
                                                    <option value="1">上架状态</option>
                                                    <option value="3" <{if isset($data.sj) AND $data.sj == 3}>selected<{/if}>>已上架</option>
                                                    <option value="2" <{if isset($data.sj) AND $data.sj == 2}>selected<{/if}>>未上架</option>
                                                </select>
                                            </div>
                                            
                                            <div class="layui-inline">
                                                <button type="submit" class="layui-btn">搜索</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </fieldset>
                            <!--商品列表 star-->
                            <form class="layui-form layui-form-pane1" method="post" delete_action="/subject/delete">
                                <table class="layui-table" lay-even lay-skin="row">
                                    <thead>
                                        <tr>
                                            <tr>
                                                <th>课程</th>
                                                <th>分类</th>
                                                <th>上架价格</th>
                                                <th>佣金比例</th>
                                                <th>有效天数</th>
                                                <th>激活码(已使用/总数/冻结数)</th>
                                                <th>上架时间</th>
                                                <th>操作</th>
                                            </tr>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <{foreach from=$zhiboke item=item}>
                                        <tr>
                                            <td class="not_lb tal">
                                                <{$item.title}>
                                            </td>
                                            <td class="not_lb tal">
                                            <{foreach from =$cate item = item_cate}>
                                            <{if $item_cate.id eq $item.cate_id}><{$item_cate.name}><{/if}>
                                            <{/foreach}>    
                                            </td>
                                            <td class="not_lb tal"><span class="c-ff6d5e"><{if isset($item.fx_price) AND $item.fx_price > 0}>¥<{$item.fx_price}>元<{/if}></span></td>
                                            <td class="not_lb tal"><span class="c-ff6d5e"><{if isset($item.fx_price) AND $item.fx_price > 0}><{$item.commission}>%<{/if}></span></td>
                                            <td class="not_lb tal"><span class="c-ff6d5e"><{if isset($item.fx_price) AND $item.fx_price > 0}><{$item.expire_day}>天<{/if}></span></td>
                                            <td class="not_lb tal"><{$item.use_code}>/<{$item.use_code+$item.nouse_code}>/<{$item.dongjie}></td>
                                            <td class="not_lb tal">
                                                <{if isset($item.fx_price) AND $item.fx_price > 0}><{$item[ 'sj_time']|date_format: '%Y-%m-%d <br> %H:%M:%S'}><{/if}></td>
                                            <td class="not_lb tal">
                                                <div class="colorBtn">
                                                    <!-- <p><span>未发布</span></p> -->

                                                    <{if $item.sjid == ""}>
                                                    <p>
                                                        <a class="up" course_id="<{$item.id}>" pack_id="<{$item.sjid|default:0}>" href="javascript:void(0);">上架</a>
                                                    </p>
                                                    <{else}>
                                                    <p><a id="sj_<{$item.id}>" onclick="shangjia(<{$item.id}>)" href="javascript:void(0);">已上架</a></p>
                                                    <a class="up" course_id="<{$item.id}>" pack_id="<{$item.sjid|default:0}>" href="javascript:void(0);">修改上架</a>
                                                    <{/if}>
                                                    <p>
                                                        <a href="/shelves/shouquan/<{$item.id}>/1" target="_blank">申请授权码</a>
                                                    </p>
                                                    <a class="show_system_topic" url="/order_course_auth/school_order_records/<{$item.id}>/1" href="javascript:;">查看授权码</a>
                                                </div>
                                            </td>
                                        </tr>
                                    <{/foreach}>
                                    <{if $zhiboke|count eq 0}>
                                        <tr>
                                            <td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="8">
                                                赞无数据！
                                            </td>
                                        </tr>
                                    <{/if}>
                                    </tbody>
                                </table>
                            </form>


                            
                                            <div class="pages p-tb20">
                                                <{$pagination}>
                                            </div>
                                        </div>
                                    </div>
                                    <!--end mc-->
                                </div>

                            </div>
                            <!--商品列表 end -->
                        </div>
                        <!--end tabMainCont-->
                    </div>

                </div>
            </div>
            <!--end内容区域-->
            <{include file="footer.html"}>
            <script type="text/javascript">
                $(".up").click(function(){
                    layer.open({
                        type: 2,
                        title: '科目上架',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['500px', '400px'],
                        maxmin: true,
                        content: '/shelves/up/'+$(this).attr("course_id")+'/'+$(this).attr("pack_id") //iframe的url
                    });
                })

                $(".down").click(function(){
                    $.ajax({
                        type: "POST",
                        url: "/subject/shelves_down/" + $(this).attr("pack_id"),
                        dataType:"json",
                        async:false,
                        data:{'subject_id':$(this).attr("subject_id"),'pack_id':$(this).attr("pack_id")},
                        contentType:'application/x-www-form-urlencoded',
                        success: function(result){
                            if(result.code == 1){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index);
                                parent.layer.msg('已下架', {
                                    icon: 1,
                                    shade:0.5,
                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                });
                            }
                        }
                    });
                })
            </script>
<script type="text/javascript">
function shangjia(id){
    if($("#sj_"+id).text() == "已上架"){
        $.ajax({
            type: "POST",
            url: "/shelves/sj",
            data: "id="+id,
            async: false,
            dataType: "json",
            success: function(data) {
                window.location.reload();
            }
        });
    }else{
        layer.open({
            type: 1,
            title: '设置分销信息',
            area: ['500px', '400px'],
            content:'<div class="line-all p20"><form class="layui-form layui-form-pane" method="post" action="/shelves/sj" onsubmi="return false;" id="form_add_video_course"><input type="hidden" class="course" name="id" value="" /><div class="layui-form-item"><label class="layui-form-label">价格:</label><div class="layui-input-inline"><input type="text" value="<{$info.price|default:''}>" placeholder="请输入价格" name="fx_price" lay-verify="required" autocomplete="off" class="layui-input"></div><div class="layui-form-mid layui-word-aux">元</div></div><div class="layui-form-item"><label class="layui-form-label">佣金:</label><div class="layui-input-inline"><input type="text" value="<{$info.price|default:''}>" placeholder="请输入百分比" name="commission" lay-verify="required" autocomplete="off" class="layui-input"></div><div class="layui-form-mid layui-word-aux">%</div></div><div class="layui-form-item"><label class="layui-form-label">课程分类：</label><div class="layui-input-inline"><select style="height:38px;display:block" name="cate_id" lay-verify="required" id="cate_id" placeholder="请选择" lay-filter="subject"><{foreach from=$cate item=item}><option value="<{$item.id}>" ><{$item.name}></option><{/foreach}></select></div></div><div class=""><label class="layui-form-label">VIP免费:</label><input type="checkbox" value="1" name="is_free" title="免费" ><div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary"><span>免费</span><i class="layui-icon"></i></div></div><button class="layui-btn" lay-submit lay-filter="*">立即提交</button></from></div>',
            // content:'<form class="layui-form"><div class="layui-form-item"><label class="layui-form-label">下拉选择框</label><div class="layui-input-block"><select name="interest" lay-filter="aihao"><option value="0">写作</option><option value="1">阅读</option></select></div></div></form>',

            
        });     
        $(".course").val(id);
        layui.use(['form'], function(){
            var form = layui.form();
            form.render('checkbox');

        });
    }
}
$(".show_system_topic").click(function(){
    layer.open({
        type: 2,
        title: '激活码列表',
        shadeClose: true,
        shade: 0.8,
        area: ['90%', '90%'],
        maxmin: true,
        content: $(this).attr("url") //iframe的url
    }); 
})
</script>